﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace DTOTemplatedGenerator
{
	public class RelayCommand : ICommand
	{
		public event EventHandler CanExecuteChanged;
		
		private Action _action;
		private Func<bool> _canExecute;
		public RelayCommand(Action action, Func<bool> canExecute)
		{
			_action = action;
			_canExecute = canExecute;
		}
		public RelayCommand(Action action)
			: this(action, null)
		{
		}

		public bool CanExecute(object parameter)
		{
			if (_canExecute == null)
			{
				return true;
			}
			else
			{
				return _canExecute();
			}
		}
		public void Execute(object parameter)
		{
			_action();
		}
	}
}
